<#assign f=JspTaglibs["http://www.casic304.cn/f"] />
<div>
    <table id="wQbdQcGroupTable" lay-filter="wQbdQcGroupTable"></table>
    <form class="reportList-isShow">
        <input type="hidden" id="successDataId" name="successDataId">
    </form>
</div>
<!-- 右侧工具栏 -->
<script type="text/html" id="wQbdQcGroupRightToolsBar">
    <a class="RightBtn" lay-event="particulars">详情</a>
</script>

<script>
    //一般直接写在一个js文件中
    layui.use(['index','table','common','publicMethods','jquery','layer'], function () {
        var table = layui.table;
        var common = layui.common;
        var publicMethods = layui.publicMethods;
        var $ = layui.jquery;
        var layer = layui.layer;

        var tableH=publicMethods.layerHeight();
        var dataId = "${dataId}";

        var orderCols = [{type: 'checkbox', fixed: 'left'},{field: 'sn', type: 'numbers', title: '序号', fixed: 'left'}];
        var commonCols = [
            { field: 'registerdept', title: '注册单位', minWidth: 140 }
            , { field: 'registernum', title: '注册编号', minWidth: 140 }
            , { field: 'groupname', title: 'QC小组名称',  minWidth: 150 }
            , { field: 'subjectname', title: '课题名称', minWidth: 140 }
            , { field: 'groupleader', title: '组长', minWidth: 90 }
            , {
                field: 'registerdate', title: '注册时间', minWidth: 140, templet: function (d) {
                    return publicMethods.timeData(d.registerdate);
                }
            }
        ];

        var manageCols =[{
            fixed: 'right',
            title: '管理',
            align:'center',
            toolbar: '#wQbdQcGroupRightToolsBar',
            minWidth: 80
        }];

        var totalCols = [];
        totalCols = totalCols.concat(orderCols).concat(commonCols).concat(manageCols);

        //第一个实例
        table.render({
            elem: '#wQbdQcGroupTable'
            ,height:tableH
            ,url: serverPath.qbdmsPath + '/qbdms/wQbdQcGroup/reportList?id=' + dataId + "&tableName=W_QBD_QC_GROUP"
            ,page: false //开启分页
            // ,toolbar: '#wQbdQcGroupHeaderToolsBar'
            ,method: 'post'
            ,autoSort: false //是否排序
            ,cols: [totalCols],done:function () {
            }
        });

        table.on('tool(wQbdQcGroupTable)', function(obj) {
            var data = obj.data, //获得当前行数据
                    layEvent = obj.event; //获得 lay-event 对应的值
            switch(layEvent){
                case "particulars":
                    var height=publicMethods.layHeight('body');
                    layer.open({
                        type: 2,
                        area: ['96%', height],
                        title: ['QC小组注册详情'],
                        content: serverPath.qbdmsPath + '/qbdms/wQbdQcGroup/view/particulars?id=' + data.id + "&isClose=true"
                    });
                    break;
            }
        });

        table.on('checkbox(wQbdQcGroupTable)', function (obj) {
            if (obj.type == "all") {
                if (obj.checked) {
                    $("input[name='successDataId']").val("");
                    var checkStatus = table.checkStatus('wQbdQcGroupTable');
                    var valArr = checkStatus.data;//选中行数据
                    var ceshiVal = $("input[name='successDataId']").val();
                    for (var i = 0; i < valArr.length; i++) {
                        ceshiVal = ceshiVal + valArr[i].id + ",";
                    }
                    $("input[name='successDataId']").val(ceshiVal);
                } else {
                    $("input[name='successDataId']").val("");
                }
            } else {
                if (obj.checked) {
                    var ceshiVal = $("input[name='successDataId']").val();
                    $("input[name='successDataId']").val(ceshiVal + obj.data.id + ",");
                } else {
                    var ceshiVal = $("input[name='successDataId']").val();
                    var newVal = "";
                    var valArr = ceshiVal.split(obj.data.id + ",");
                    for (var i = 0; i < valArr.length; i++) {
                        newVal += valArr[i];
                    }
                    $("input[name='successDataId']").val(newVal);
                }
            }
        });

    });
</script>
</body>
</html>